<?php
include_once('config/config.php');

$LoginAdmin = auth();
if (!empty($_GET['id'])) {
  $id = $_GET['id'];
  $sql = "SELECT * FROM `stu_department` WHERE `id` = $id";
  $Data = find($sql);
}
if($_POST){
  $data = [
    'name'=>$_POST['depname'],
    'minister'=>$_POST['mininame'],
  ];
  $result = update('department',$data,"`id` = '$id'");
  if($result){
    ShowMsg('更新成功','departmentlist.php');
  }else{
    ShowMsg('更新失败','departmentlist.php');
  }
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <?php include_once('common/meta.php') ?>
</head>
<style>
  input[type="file"] {
    display: none;
  }

  label[for="avatar"] {
    width: 200px;
  }
</style>

<body>
  <!--<![endif]-->

  <!-- 引用头部 -->
  <?php include_once('common/header.php') ?>

  <!-- 引用菜单 -->
  <?php include_once('common/nav.php') ?>

  <div class="content">
    <div class="header">
      <h1 class="page-title">系部编辑页</h1>
    </div>
    <ul class="breadcrumb">
      <li><a href="index.php">Home</a> <span class="divider">/</span></li>
      <li><a href="adminlist.php">DepartmentList</a> <span class="divider">/</span></li>
      <li class="active">DepartmentEdit</li>
    </ul>

    <div class="container-fluid">
      <div class="row-fluid">

        <div class="btn-toolbar">
          <button class="btn btn-primary" onClick="location='departmentlist.php'"><i class="icon-list"></i>系部列表</button>
          <div class="btn-group">
          </div>
        </div>

        <div class="well">
          <div id="myTabContent" class="tab-content">
            <div class="tab-pane active in" id="home">
              <form method="post" enctype="multipart/form-data">
                <label>系部名称</label>
                <input type="text" name="depname" value="<?php echo $Data['name'] ?>" required class="input-xxlarge" placeholder="修改部门名称">
                <label>系部院长</label>
                <input type="text" name="mininame" value="<?php echo $Data['minister'] ?>" required class="input-xxlarge" placeholder="修改院长名称">
                <label></label>
                <input class="btn btn-primary" type="submit" value="修改" />
              </form>
            </div>
          </div>
        </div>


        <?php include_once('common/footer.php'); ?>

      </div>
    </div>
  </div>
</body>

</html>
<?php include_once('common/script.php'); ?>